import { viteMockServe } from 'vite-plugin-mock'
import { UserConfigExport, ConfigEnv, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'
import styleImport, { VantResolve } from 'vite-plugin-style-import'
// https://vitejs.dev/config/
export default ({ command, mode }: ConfigEnv): UserConfigExport => {
	return {
		plugins: [
			vue(),
			styleImport({
				resolves: [VantResolve()],
			}),
			viteMockServe({
				// default
				mockPath: 'mock',
				localEnabled: command === 'serve',
			}),
		],
		resolve: {
			//设置别名
			alias: {
				'@': path.resolve(__dirname, 'src'),
			},
		},
		server: {
			port: 3001,
			hmr: {
				host: '127.0.0.1',
				port: 3001,
			},
			// 设置 https 代理
			// proxy: {
			//   '/api': {
			//     target: 'your https address',
			//     changeOrigin: true,
			//     rewrite: (path: string) => path.replace(/^\/api/, '')
			//   }
			// }
		},
	}
}
